package com.yida.gwj.report.service.impl;

import com.yida.common.core.utils.StringUtils;
import com.yida.gwj.common.constant.GwjConstants;
import com.yida.gwj.common.enums.GwjBusinessStatus;
import com.yida.gwj.report.domain.dto.GwjFinanceMoneyDTO;
import com.yida.gwj.report.domain.dto.GwjFinanceMoneyMonthDTO;
import com.yida.gwj.report.domain.dto.GwjFinanceMoneyYearDTO;
import com.yida.gwj.report.domain.request.GwjFinanceMoneyQueryRequest;
import com.yida.gwj.report.domain.request.GwjReportFinanceMoneyQueryRequest;
import com.yida.gwj.report.mapper.GwjFinanceMoneyMapper;
import com.yida.gwj.report.service.IGwjFinanceMoneyService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 缴存金额收入总帐明细Service业务层处理
 *
 * @author lqq
 * @date 2022-12-28
 */
@Service
public class GwjFinanceMoneyServiceImpl implements IGwjFinanceMoneyService {

	@Resource
	private GwjFinanceMoneyMapper financeMoneyMapper;

	/**
	 * 查询缴存金额收入总帐明细列表（详情含业务信息）
	 *
	 * @param request 缴存金额收入总帐明细
	 * @return 缴存金额收入总帐明细集合
	 */
	@Override
	public List<GwjFinanceMoneyDTO> selectFinanceMoneyDetailList(GwjFinanceMoneyQueryRequest request) {
		return financeMoneyMapper.selectFinanceMoneyDetailList(request);
	}

	/**
	 * 查询缴存金额收入总帐明细列表
	 *
	 * @param request 缴存金额收入总帐明细请求
	 * @return 缴存金额收入总帐明细
	 */
	@Override
	public List<GwjFinanceMoneyYearDTO> getYearReport(GwjReportFinanceMoneyQueryRequest request) {
		//处理是否案例回顾
		if (StringUtils.isNotBlank(request.getFinishFlag())) {
			if (request.getFinishFlag().equals(GwjConstants.YES)) {
				request.setFinishYes(GwjBusinessStatus.FINISH.getCode());
			} else {
				request.setFinishNo(GwjBusinessStatus.FINISH.getCode());
			}
		}
		return financeMoneyMapper.statisticsByYear(request);
	}

	/**
	 * 查询缴存金额收入总帐明细列表
	 *
	 * @param request 缴存金额收入总帐明细
	 * @return 缴存金额收入总帐明细
	 */
	@Override
	public List<GwjFinanceMoneyMonthDTO> getMonthReport(GwjReportFinanceMoneyQueryRequest request) {
		//处理是否案例回顾
		if (StringUtils.isNotBlank(request.getFinishFlag())) {
			if (request.getFinishFlag().equals(GwjConstants.YES)) {
				request.setFinishYes(GwjBusinessStatus.FINISH.getCode());
			} else {
				request.setFinishNo(GwjBusinessStatus.FINISH.getCode());
			}
		}
		return financeMoneyMapper.statisticsByMonth(request);
	}
}
